<?php

use Illuminate\Support\Facades\Route;

Route::group(['prefix' => '/admin'], function () {
  // 登录页面展示
  Route::post('/login', 'Admin\UserController@login');

  // 根据id获取分类信息
  Route::get('/cate/{id}', 'Admin\CateController@getCateById')->middleware('checklogin');
  // 添加栏目
  Route::post('/cate', 'Admin\CateController@addCate')->middleware('checklogin');
  // 删除栏目
  Route::delete('/cate/{id}', 'Admin\CateController@removeCateById')->middleware('checklogin');
  // 修改栏目
  Route::put('/cate/{id}', 'Admin\CateController@updateCateById')->middleware('checklogin');
  // 根据id修改栏目排序
  Route::put('/cate/sort/{id}', 'Admin\CateController@updateCateById')->middleware('checklogin');

  // 获取内容
  Route::get('/content/{cid?}', 'Admin\ContentController@getContentList')->middleware('checklogin');
  // 根据id获取内容
  Route::get('/content/{id}', 'Admin\ContentController@getContentById')->middleware('checklogin');
  // 添加内容
  Route::post('/content', 'Admin\ContentController@addContent')->middleware('checklogin');
  // 删除内容
  Route::delete('/content/{id}', 'Admin\ContentController@removeContentById')->middleware('checklogin');
  // 修改内容
  Route::put('/content/{id}', 'Admin\ContentController@updateContentById')->middleware('checklogin');

  // 获取广告位
  Route::get('/adv', 'Admin\AdvController@getAdvList')->middleware('checklogin');
  // 根据id获取广告位信息
  Route::get('/adv/{id}', 'Admin\AdvController@getAdvById')->middleware('checklogin');
  // 添加广告位
  Route::post('/adv', 'Admin\AdvController@addAdv')->middleware('checklogin');
  // 根据id修改广告位
  Route::put('/adv/{id}', 'Admin\AdvController@updateAdvById')->middleware('checklogin');
  // 根据id删除广告位
  Route::delete('/adv/{id}', 'Admin\AdvController@deleteAdvById')->middleware('checklogin');

  // 获取广告位内容
  Route::get('/advcontent', 'Admin\AdvContentController@getAdvContent')->middleware('checklogin');
  // 根据id获取广告位内容
  Route::get('/advcontent/{id}', 'Admin\AdvContentController@getAdvContentById')->middleware('checklogin');
  // 添加广告位内容
  Route::post('/advcontent', 'Admin\AdvContentController@addAdvContent')->middleware('checklogin');
  // 根据id删除广告位内容
  Route::delete('/advcontent/{id}', 'Admin\AdvContentController@removeAdvContentById')->middleware('checklogin');
  // 根据id修改广告位内容
  Route::put('/advcontent/{id}', 'Admin\AdvContentController@updateAdvContentById')->middleware('checklogin');

  // 上传图片
  Route::post('/upload', 'Admin\UploadController@addImageToUpload')->middleware('checklogin');
});

Route::group(['prefix' => '/home'], function () {
  // 登录路由
  Route::post('/login', 'Home\UserController@login');
  // 注册路由
  Route::post('/registe', 'Home\UserController@registe');

  // 获取分类列表路由
  Route::get('/cate', 'Home\HomeController@getCateList');
  // 获取轮播图列表路由
  Route::get('/swiper', 'Home\HomeController@getSwiperList');
  // 获取广告列表路由
  Route::get('/adv', 'Home\HomeController@getAdvList');

  // 获取文章列表路由
  Route::get('/content', 'Home\ContentController@getContentList');
  // 根据分类id获取文章列表路由
  Route::get('/content/{cid}', 'Home\ContentController@getContentByCid');
  // 获取热门内容
  Route::get('/hot', 'Home\ContentController@getHotContent');

  // 根据id获取详情信息
  Route::get('/detail/{id}', 'Home\DetailController@getDetailById');
  // 点赞
  Route::post('/like/{id}', 'Home\DetailController@addLike');
  // 添加评论
  Route::post('/comment', 'Home\DetailController@addComment');
});
